/*
欧拉函数φ(1337)=φ(7)*φ(191)=6*190=1140
a^φ(b)≡1 (mod b)
 */
public class Solution372 {
    public int superPow(int a, int[] b) {
        a=a%1337;
        int t=0;
        for (int i : b) {
            t=(t*10+i)%1140;
        }
        int ans=1;
        for (int i = 0; i < t; i++) {
            ans=ans*a%1337;
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution372().superPow(2147483647,new int[]{2,0,0}));
    }
}
